import dynamic from 'dva/dynamic';

// wrapper of dynamic
const dynamicWrapper = (app, models, component) => dynamic({
  app,
  models: () => models.map(m => import(`../models/${m}.js`)),
  component,
});
// nav data
export const getNavData = app => [
  {
    component: dynamicWrapper(app, ['user', 'login', 'control'], () => import('../layouts/BasicLayout')),
    layout: 'BasicLayout',
    name: '首页', // for breadcrumb
    path: '/',
    children: [
      {
        name: '账号管理',
        icon: 'user',
        path: 'account',
        children: [
          {
            name: '用户管理',
            path: 'user',
            component: dynamicWrapper(app, ['userManage'], () => import('../routes/AccountManagement/UserManagement')),
          },
          {
            name: '师傅管理',
            path: 'master',
            component: dynamicWrapper(app, ['masterManage', 'general'], () => import('../routes/AccountManagement/MasterManagement')),
          },
          {
            name: '操作员管理',
            path: 'manager',
            component: dynamicWrapper(app, ['sysUser'], () => import('../routes/AccountManagement/ManagersManagement')),
          },
          {
            name: '订单列表',
            path: 'auditorder',
            component: dynamicWrapper(app, ['packageOrder'], () => import('../routes/AdminManagement/AuditOrder')),
          },
          {
            name: '审核订单',
            path: 'auditorderdetails',
            component: dynamicWrapper(app, ['packageOrder', 'immanage', 'general'], () => import('../routes/AdminManagement/AuditOrderDetails')),
          },
          {
            name: '审核通过',
            path: 'installationworksheet',
            component: dynamicWrapper(app, ['immanage'], () => import('../routes/AdminManagement/InstallationWorksheet')),
          },
          {
            name: '审核不通过',
            path: 'auditfailure',
            component: dynamicWrapper(app, ['bussiness'], () => import('../routes/AdminManagement/AuditFailure')),
          },
          {
            name: '待审报修订单',
            path: 'repairorder',
            component: dynamicWrapper(app, ['immanage'], () => import('../routes/AdminManagement/RepairOrder')),
          },
          {
            name: '未完结工单',
            path: 'workorde',
            component: dynamicWrapper(app, ['immanage'], () => import('../routes/AdminManagement/WorkOrde')),
          },
          {
            name: '待审提速订单',
            path: 'speeduporder',
            component: dynamicWrapper(app, ['packageOrder'], () => import('../routes/AdminManagement/SpeedUpOrder')),
          },
          {
            name: '待审续费订单',
            path: 'reneworder',
            component: dynamicWrapper(app, ['packageOrder'], () => import('../routes/AdminManagement/RenewOrder')),
          },
          {
            name: '报修订单通过',
            path: 'repairorderpass',
            component: dynamicWrapper(app, ['immanage'], () => import('../routes/AdminManagement/RepairOrderPass')),
          },
          {
            name: '工单',
            path: 'workordepass',
            component: dynamicWrapper(app, ['immanage'], () => import('../routes/AdminManagement/WorkOrdePass')),
          },
          {
            name: '提速订单通过',
            path: 'speeduporderpass',
            component: dynamicWrapper(app, ['packageOrder'], () => import('../routes/AdminManagement/SpeedUpOrderPass')),
          },
          {
            name: '续费订单通过',
            path: 'reneworderpass',
            component: dynamicWrapper(app, ['packageOrder'], () => import('../routes/AdminManagement/RenewOrderPass')),
          },
          {
            name: '待审报修订单详情',
            path: 'repairorderdetails',
            component: dynamicWrapper(app, ['immanage', 'general'], () => import('../routes/AdminManagement/RepairOrderDetails')),
          },
          {
            name: '未完结工单详情',
            path: 'workordedetails',
            component: dynamicWrapper(app, ['immanage'], () => import('../routes/AdminManagement/WorkOrdeDetails')),
          },
          {
            name: '待审提速订单详情',
            path: 'speeduporderdetails',
            component: dynamicWrapper(app, ['packageOrder'], () => import('../routes/AdminManagement/SpeedUpOrderDetails')),
          },
          {
            name: '待审续费订单详情',
            path: 'reneworderdetails',
            component: dynamicWrapper(app, ['packageOrder'], () => import('../routes/AdminManagement/RenewOrderDetails')),
          },
          {
            name: '审核不通过',
            path: 'repairorderfailure',
            component: dynamicWrapper(app, ['bussiness'], () => import('../routes/AdminManagement/RepairOrderFailure')),
          },
          {
            name: '审核不通过',
            path: 'workordefailure',
            component: dynamicWrapper(app, ['bussiness'], () => import('../routes/AdminManagement/WorkOrdeFailure')),
          },
          {
            name: '审核不通过',
            path: 'speeduporderfailure',
            component: dynamicWrapper(app, ['bussiness'], () => import('../routes/AdminManagement/SpeedUpOrderFailure')),
          },
          {
            name: '审核不通过',
            path: 'reneworderfailure',
            component: dynamicWrapper(app, ['bussiness'], () => import('../routes/AdminManagement/RenewOrderFailure')),
          },
          {
            name: '',
            path: 'admin',
            component: dynamicWrapper(app, ['form'], () => import('../routes/AdminManagement/AdminManagement')),
          },
          {
            name: '',
            path: 'index',
            component: dynamicWrapper(app, ['control'], () => import('../routes/AdminManagement/Index')),
          },
          {
            name: '',
            path: 'message',
            component: dynamicWrapper(app, ['project', 'activities', 'chart'], () => import('../routes/AdminManagement/MessageManagement')),
          },
        ],
      },
      {
        name: '宽带管理',
        path: 'broadband',
        icon: 'form',
        children: [
          {
            name: '业务管理',
            path: 'business',
            component: dynamicWrapper(app, ['bussiness', 'general'], () => import('../routes/BroadbandManagement/BusinessManagement')),
          },
          {
            name: '套餐管理',
            path: 'combo',
            component: dynamicWrapper(app, ['packages', 'general'], () => import('../routes/BroadbandManagement/PackageManagement')),
          },
          {
            name: '区域管理',
            path: 'district',
            component: dynamicWrapper(app, ['district', 'general'], () => import('../routes/BroadbandManagement/DistrictManagement')),
          },
          {
            name: '小区管理',
            path: 'community',
            component: dynamicWrapper(app, ['community', 'general'], () => import('../routes/BroadbandManagement/CommunityManagement')),
          },
        ],
      },
      {
        name: '用户宽带管理',
        path: 'broadbandUser',
        icon: 'user',
        children: [
          {
            name: '用户宽带管理',
            path: 'broadband',
            component: dynamicWrapper(app, ['userBroad', 'general'], () => import('../routes/UserBroadbandManagement/BroadbandManagement')),
          },
          {
            name: '后台操作用户业务',
            path: 'operat',
            component: dynamicWrapper(app, ['profile'], () => import('../routes/UserBroadbandManagement/OperatManagement')),
          },
        ],
      },
      {
        name: '套餐订单',
        path: 'combo',
        icon: 'table',
        children: [
          {
            name: '业务订单',
            path: 'business',
            component: dynamicWrapper(app, ['packageOrder', 'general'], () => import('../routes/PackageManagement/BusinessOrder')),
          },
          {
            name: '退款订单',
            path: 'refund',
            component: dynamicWrapper(app, ['rule'], () => import('../routes/PackageManagement/RefundOrder')),
          },
        ],
      },
      {
        name: '装维订单',
        path: 'fitted',
        icon: 'profile',
        children: [
          {
            name: '装维订单',
            path: 'order',
            component: dynamicWrapper(app, ['immanage', 'general'], () => import('../routes/FittedManagement/OrderList')),
          },
        ],
      },
      {
        name: '报表统计',
        path: 'report',
        icon: 'profile',
        children: [
          {
            name: '财务报表',
            path: 'finance',
            component: dynamicWrapper(app, ['rule'], () => import('../routes/ReportManagement/FinanceList')),
          },
          {
            name: '师傅绩效',
            path: 'master',
            component: dynamicWrapper(app, ['rule'], () => import('../routes/ReportManagement/MasterList')),
          },
          {
            name: '推荐人绩效',
            path: 'recommend',
            component: dynamicWrapper(app, ['rule'], () => import('../routes/ReportManagement/RecommendList')),
          },
        ],
      },
      {
        name: '权限管理',
        path: 'permission',
        icon: 'check-circle-o',
        children: [
          {
            name: '角色管理',
            path: 'role',
            component: dynamicWrapper(app, ['rule'], () => import('../routes/PermissionsManagement/RoleList')),
          },
        ],
      },
      {
        name: '系统日志',
        path: 'system',
        icon: 'check-circle-o',
        children: [
          {
            name: '操作日志',
            path: 'log',
            component: dynamicWrapper(app, [], () => import('../routes/SystemManagement/OperationLog')),
          },
        ],
      },
    ],
  },
  {
    component: dynamicWrapper(app, [], () => import('../layouts/UserLayout')),
    path: '/user',
    layout: 'UserLayout',
    children: [
      {
        name: '帐户',
        icon: 'user',
        path: 'user',
        children: [
          {
            name: '登录',
            path: 'login',
            component: dynamicWrapper(app, ['login'], () => import('../routes/User/Login')),
          },
          {
            name: '注册',
            path: 'register',
            component: dynamicWrapper(app, ['register'], () => import('../routes/User/Register')),
          },
          {
            name: '注册结果',
            path: 'register-result',
            component: dynamicWrapper(app, [], () => import('../routes/User/RegisterResult')),
          },
        ],
      },
    ],
  },
];
